/*
 * Copyright (c) 2007 Compl Yue Still, All Rights Reserved.
 */

package hbi.wire.as3.host
{
	import flash.utils.*;
	import hbi.wire.ProtocolError;

	public class BoolElement implements DataTag
	{
		
		private var _value:*;
		
		public function get tagValue():*
		{
			return _value;
		}
		
		public function reset():void
		{
			_value = undefined;
		}
		
		public function processIncomingData(input:IDataInput):Boolean
		{
			if(input.bytesAvailable < 1) return false;
			var tag:int = input.readUnsignedByte();
			switch(tag)
			{
			case 'T'.charCodeAt():
				_value = true;
				break;
			case 'F'.charCodeAt():
				_value = false;
				break;
			default:
				throw new ProtocolError("Bad boolean value: " + tag);
			}
			return true;
		}
		
	}
}
